Add explicit permissions to GitHub Actions workflows#141
Conversation
Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR enhances security by adding explicit permissions to GitHub Actions workflows, following the principle of least privilege. Both workflow files previously relied on default permissions, which could grant more access than necessary.
Key Changes:
- Added
permissions: contents: readto both workflows at the workflow level - Ensures workflows have minimal required permissions for their operations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
.github/workflows/nodejs.yml |
Added explicit read-only content permission for CI testing workflow |
.github/workflows/publish.yml |
Added explicit read-only content permission for npm publishing workflow |
The changes are correctly implemented. Both workflows only perform read operations on the repository (checking out code, running tests) and use external authentication (NPM_TOKEN) for publishing, requiring no additional GitHub permissions beyond contents: read. The YAML syntax is correct, and the permissions blocks are properly placed at the workflow level with appropriate indentation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Two workflow files lacked explicit permission declarations, relying on default permissions.
Changes
permissions: contents: readto.github/workflows/nodejs.ymlpermissions: contents: readto.github/workflows/publish.ymlBoth workflows only require repository read access for
actions/checkout@v3. The publish workflow usesNPM_TOKENfor external registry authentication, requiring no additional GitHub permissions.Before:
After:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.